package com.lancoo.znbkxx.teacher.ui.fragment

import androidx.recyclerview.widget.GridLayoutManager
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.adapter.EvenItemDecoration
import com.lancoo.znbkxx.teacher.adapter.StuProgressAdapter
import com.lancoo.znbkxx.teacher.base.BaseVMFragment
import com.lancoo.znbkxx.teacher.databinding.FmtReviewBinding
import com.lancoo.znbkxx.teacher.model.data.StuProgressInfo
import com.lancoo.znbkxx.teacher.utils.DensityUtils
import com.lancoo.znbkxx.teacher.viewmodel.CommentViewModel
import kotlinx.android.synthetic.main.fmt_stu_progress.*

/**
 * Created by wealive on 2021/3/9.
 *
 *
 */
class StuProgressFragment : BaseVMFragment<CommentViewModel, FmtReviewBinding>() {
    private val stuList by lazy {
        requireArguments().getParcelableArrayList<StuProgressInfo>("info")
    }
    private lateinit var adapter: StuProgressAdapter

    override fun setLayoutID(): Int {
        return R.layout.fmt_stu_progress
    }

    override fun providerContext(): Any? {
        return this
    }

    override fun providerVMClass(): Class<CommentViewModel>? {
        return CommentViewModel::class.java
    }

    override fun initView() {
        adapter = StuProgressAdapter(R.layout.item_stu_progress, stuList)
        adapter.emptyView = layoutInflater.inflate(R.layout.item_stu_progress_empty, null)
        rv.layoutManager = GridLayoutManager(requireContext(), 3)
        rv.addItemDecoration(EvenItemDecoration(DensityUtils.dp2px(activity, 10f), 3))
        rv.adapter = adapter
    }
}